<ui:composition xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	template="template/template.xhtml">
	<ui:define name="title">
		<h:outputText value="#{msgs.iterationAssignment}"/>
	</ui:define>
	<ui:define name="bodyInclude">
		<ui:include src="include/menu.xhtml" />
		<p:fieldset legend="#{msgs.prioritizationOfTheHierarchy}: #{iterationAssignmentController.currentHierarchy.project.name} - #{iterationAssignmentController.currentHierarchy.version.name}" toggleable="true">
			<h:form id="iterationAssignmentForm">
				<p:outputPanel layout="block" rendered="#{iterationAssignmentController.currentIterationCompleted and 0 == iterationAssignmentController.currentIterationScriptsCount}" styleClass="checkMessage">
					<h:outputText value="#{msgs.endedPrioritizationForThisVersion}"/>
				</p:outputPanel>
				<p:outputPanel layout="block" styleClass="container">
					<h:panelGrid cellpadding="5" columns="2">
						<h:outputText styleClass="bold" value="#{msgs.currentIteration}: " />
						<h:outputText value="#{iterationAssignmentController.currentIterationScriptsCount} #{msgs.scripts}" />
						<h:outputText styleClass="bold" value="#{msgs.remainingIterationsAfterThisOne}: " />
						<h:outputText value="#{iterationAssignmentController.currentRemainingIterations}" />
					</h:panelGrid>
					<p:dataTable emptyMessage="#{msgs.emptyDataTableMessage}" id="iterationAssignmentsTable" paginator="false" rendered="#{null != iterationAssignmentController.currentIterationAssignments and not empty iterationAssignmentController.currentIterationAssignments}" value="#{iterationAssignmentController.currentIterationAssignments}" var="iterationAssignment">
						<p:column headerText="#{msgs.criterion}" sortBy="#{iterationAssignment.criterionType}" styleClass="center">
							<h:outputText value="#{iterationAssignment.criterionTypeTranslation}"/>
						</p:column>
						<p:column headerText="#{msgs.status}" sortBy="#{iterationAssignment.analyticalStatus}" styleClass="center">
							<h:outputText value="#{iterationAssignment.analyticalStatusTranslation}" />
						</p:column>
						<p:column headerText="#{msgs.responsableService}" sortBy="#{iterationAssignment.service.label}" styleClass="center">
							<h:outputText rendered="#{null != iterationAssignment.service}" value="#{iterationAssignment.service.label}" />
							<p:inplace effect="slide" effectSpeed="fast" emptyLabel="#{msgs.clickHereToUpdateThisField}" rendered="#{null == iterationAssignment.service}"  styleClass="buttonContainer" widgetVar="serviceInplace#{iterationAssignment.iterationAssignmentId}">
								<h:selectOneMenu value="#{iterationAssignment.serviceId}">
									<f:selectItems value="#{iterationAssignmentController.availablesServices}" />
								</h:selectOneMenu>
								<p:commandButton action="#{iterationAssignmentController.onIterationUpdate}" ajax="true" alt="#{msgs.updateValue}" image="ui-icon ui-icon-check" oncomplete="serviceInplace#{iterationAssignment.iterationAssignmentId}.hide()" process="@parent" title="#{msgs.updateValue}" update="iterationAssignmentForm:iterationAssignmentsTable">
									<f:setPropertyActionListener target="#{iterationAssignmentController.currentIterationToUpdate}" value="#{iterationAssignment}" />
								</p:commandButton>
							</p:inplace>
						</p:column>
					</p:dataTable>
					<p:outputPanel layout="block" rendered="#{not iterationAssignmentController.currentIterationCompleted or null == iterationAssignmentController.currentIterationAssignments or empty iterationAssignmentController.currentIterationAssignments }" styleClass="buttonContainer center">
						<p:commandButton action="#{selectivePrioritizationController.onSelectivePrioritization}" alt="#{msgs.selectivePrioritization}" image="ui-icon ui-icon-copy" process="@this" rendered="#{(null == iterationAssignmentController.currentIterationAssignments or empty iterationAssignmentController.currentIterationAssignments) and not iterationAssignmentController.currentIterationCompleted}" title="#{msgs.selectivePrioritization}" value="#{msgs.selectivePrioritization}">	
							<f:setPropertyActionListener target="#{selectivePrioritizationController.currentIteration}" value="#{iterationAssignmentController.currentIteration}" />
						</p:commandButton>
						<p:commandButton action="#{iterationAssignmentController.onCreateNextIteration}" alt="#{msgs.createNextIteration}" image="ui-icon ui-icon-pencil" rendered="#{0 != iterationAssignmentController.currentRemainingIterations and iterationAssignmentController.currentIterationCompleted}" title="#{msgs.createNextIteration}" update="iterationAssignmentForm" value="#{msgs.createNextIteration}" />
					</p:outputPanel>
				</p:outputPanel>
			</h:form>
		</p:fieldset>
	</ui:define>
</ui:composition>		